package com.training.entity;

import lombok.Data; // Import lombok library
import java.sql.Timestamp; // Import Timestamp class

// Use @Data annotation to automatically generate getters, setters, toString, equals, and hashCode methods
// We will manually override getters for classStuNum and classCouNum to handle nulls
@Data
public class Class {
    private Long id; // Class ID, corresponds to the 'id' field in the database (auto-increment primary key)
    private String className; // Class name, corresponds to the 'class_name' field in the database
    private Long teaId; // Teacher ID to whom the class belongs, corresponds to the 'tea_id' field in the database (foreign key to teacher table)
    private Integer classStuNum; // Number of students in the class, corresponds to the 'class_stu_num' field in the database
    private Integer classCouNum; // NEW: Number of courses in the class, corresponds to the 'class_cou_num' field in the database
    private Timestamp createTime; // Creation time, corresponds to the 'create_time' field in the database

    // --- MODIFIED LINE ---
    private Integer deleted = 0; // Logical deletion flag, corresponds to the 'deleted' field in the database (Default set to 0)
    // --- END MODIFIED LINE ---

    private Timestamp updateTime; // Update time, corresponds to the 'update_time' field in the database

    // Custom getter for classStuNum to ensure it's never null
    public Integer getClassStuNum() {
        return classStuNum != null ? classStuNum : 0;
    }

    // Custom getter for classCouNum to ensure it's never null
    public Integer getClassCouNum() {
        return classCouNum != null ? classCouNum : 0;
    }

    // Note: You can add more fields or custom methods if needed
    @Override
    public String toString() {
        return "Class{" +
                "id=" + id +
                ", className='" + className + '\'' +
                ", teaId=" + teaId +
                ", classStuNum=" + classStuNum +
                ", classCouNum=" + classCouNum + // Include in toString
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", deleted=" + deleted +
                '}';
    }
}